<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 罗泽楠
  Date: 2024/11/28
  Time: 上午12:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="layui/css/layui.css" rel="stylesheet">
</head>
<body>
<div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
        <ul class="layui-nav layui-nav-tree" lay-filter="test">

            <c:choose>
                <c:when test="${sessionScope.role == 'admin'}">

                    <li class="layui-nav-item" id="recipe-management" >  <a href="javascript:void(0)"  onclick="change('/recipe')">食谱管理</a></li>
                    <li class="layui-nav-item" id="daily-menu"><a href="javascript:;">每日菜单</a></li>
                    <li class="layui-nav-item" id="historical-menu"><a href="javascript:;">历史菜单</a></li>
                    <li class="layui-nav-item" id="generate-monthly-sales-report"><a href="javascript:;">月度销售统计总报表</a></li>
                    <div class="layui-nav-item" id="employee-monthly-orders-summary"><a href="javascript:;">员工月度订单汇总表</a></div>
                </c:when>

                <c:when test="${sessionScope.role == 'manager'}">
                    <li class="layui-nav-item" id="recipe-management"><a href="javascript:;">食谱管理</a></li>
                    <li class="layui-nav-item" id="blanket-order"><a href="javascript:;">总括订单</a></li>
                </c:when>

                <c:when test="${sessionScope.role == 'distributor'}">
                    <div class="layui-nav-item" id="accounting-dashboard"><a href="javascript:;">批量打印出所有的订单</a></div>
                </c:when>

                <c:when test="${sessionScope.role == 'accountant'}">
                    <li class="layui-nav-item" id="generate-monthly-sales-report"><a href="javascript:;">月度销售统计总报表</a></li>
                    <div class="layui-nav-item" id="employee-monthly-orders-summary"><a href="javascript:;">员工月度订单汇总表</a></div>
                </c:when>

                <c:when test="${sessionScope.role == 'employee'}">
                    <div class="layui-nav-item" id="employee-dashboard"><a href="javascript:;">生成订单</a></div>
                    <div class="layui-nav-item" id="work-schedule"><a href="javascript:;">个人月度销售统计汇总表</a></div>
                </c:when>
            </c:choose>

        </ul>
    </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<%--
<script>
    // 绑定各个菜单项的点击事件
    $('#recipe-management').on('click', function() {
        loadContent('recipemanage.jsp');
    });

    $('#blanket-order').on('click', function() {
        loadContent('blanketorder.jsp');
    });

    $('#accounting-dashboard').on('click', function() {
        loadContent('accountingdashboard.jsp');
    });

    $('#employee-dashboard').on('click', function() {
        loadContent('employeedashboard.jsp');
    });

    $('#work-schedule').on('click', function() {
        loadContent('workschedule.jsp');
    });

    $('#daily-menu').on('click', function() {
        loadContent('dailymenu.jsp');
    });

    $('#historical-menu').on('click', function() {
        loadContent('historicalmenu.jsp');
    });

    $('#generate-monthly-sales-report').on('click', function() {
        loadContent('generatemonthly.jsp');
    });

    $('#employee-monthly-orders-summary').on('click', function() {
        loadContent('employeemonthly.jsp');
    });

    // 通用的加载函数，根据传入的 URL 动态加载内容
    function loadContent(page) {
        // 通过 parent 访问首页的 iframe，然后修改 right.jsp iframe 中的内容
        var rightIframe = parent.document.getElementById('right-iframe'); // 获取 right.jsp 的 iframe
        var rightIframeWindow = rightIframe.contentWindow; // 获取 iframe 的 window 对象

        // 设置 #content-area 的内容为传入的页面
        $(rightIframeWindow.document).find('#content-area').load(page);
    }
</script>
--%>

<script>
    $(document).ready(function() {
        // 绑定菜单项的点击事件
        $('#recipe-management').on('click', function() {
            loadContent('/recipe'); // 通过父页面的 iframe 加载 /recipe Servlet
        });

        function loadContent(url) {
            // 获取父页面中的 right-iframe
            var rightIframe = parent.document.getElementById('right-iframe'); // 获取右侧 iframe
            // 更新 iframe 的 src 属性
            rightIframe.src = "/recipe";
        }
    });
</script>



</body>
</html>
